/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package Model;

import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeSupport;
import java.io.Serializable;
import java.util.Date;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.persistence.Transient;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author Manolis
 */
@Entity
@Table(name = "CHECKS")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Checks.findAll", query = "SELECT c FROM Checks c"),
    @NamedQuery(name = "Checks.findByCheckId", query = "SELECT c FROM Checks c WHERE c.checkId = :checkId"),
    @NamedQuery(name = "Checks.findByStatus", query = "SELECT c FROM Checks c WHERE c.status = :status"),
    @NamedQuery(name = "Checks.findByTimeStamp", query = "SELECT c FROM Checks c WHERE c.timeStamp = :timeStamp")})
public class Checks implements Serializable {
    @Transient
    private PropertyChangeSupport changeSupport = new PropertyChangeSupport(this);
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "CHECK_ID")
    private Integer checkId;
    @Basic(optional = false)
    @Column(name = "STATUS")
    private boolean status;
    @Column(name = "TIME_STAMP")
    @Temporal(TemporalType.TIMESTAMP)
    private Date timeStamp;
    @JoinColumn(name = "CUSTOMER", referencedColumnName = "CUSTOMER_ID")
    @ManyToOne(optional = false)
    private Customer customer;

    public Checks() {
    }

    public Checks(Integer checkId) {
        this.checkId = checkId;
    }

    public Checks(Integer checkId, boolean status) {
        this.checkId = checkId;
        this.status = status;
    }

    public Integer getCheckId() {
        return checkId;
    }

    public void setCheckId(Integer checkId) {
        Integer oldCheckId = this.checkId;
        this.checkId = checkId;
        changeSupport.firePropertyChange("checkId", oldCheckId, checkId);
    }

    public boolean getStatus() {
        return status;
    }

    public void setStatus(boolean status) {
        boolean oldStatus = this.status;
        this.status = status;
        changeSupport.firePropertyChange("status", oldStatus, status);
    }

    public Date getTimeStamp() {
        return timeStamp;
    }

    public void setTimeStamp(Date timeStamp) {
        Date oldTimeStamp = this.timeStamp;
        this.timeStamp = timeStamp;
        changeSupport.firePropertyChange("timeStamp", oldTimeStamp, timeStamp);
    }

    public Customer getCustomer() {
        return customer;
    }

    public void setCustomer(Customer customer) {
        Customer oldCustomer = this.customer;
        this.customer = customer;
        changeSupport.firePropertyChange("customer", oldCustomer, customer);
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (checkId != null ? checkId.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Checks)) {
            return false;
        }
        Checks other = (Checks) object;
        if ((this.checkId == null && other.checkId != null) || (this.checkId != null && !this.checkId.equals(other.checkId))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "Model.Checks[ checkId=" + checkId + " ]";
    }

    public void addPropertyChangeListener(PropertyChangeListener listener) {
        changeSupport.addPropertyChangeListener(listener);
    }

    public void removePropertyChangeListener(PropertyChangeListener listener) {
        changeSupport.removePropertyChangeListener(listener);
    }
    
}
